* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 1. 整体背景：冷调自然渐变（浅蓝→天青→浅蓝绿） */
body {
    /* 原米黄渐变→改为冷调 */
    background: linear-gradient(-45deg, #e8f4f8, #f0f8ff, #e0f7fa, #d0f0f0); 
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 2. 游戏区域背景：冷调半透明 */
.play-area {
    background: rgba(224, 247, 250, 0.2); /* 与body的#e0f7fa呼应 */
    border: 2px solid rgba(173, 216, 230, 0.3); /* 浅蓝边框 */
}

/* 3. 信息面板：冷调文字+半透明背景 */
.info-panel {
    color: #2c3e50; /* 深灰蓝文字，冷调更清晰 */
    text-shadow: 1px 1px 2px rgba(173, 216, 230, 0.3); /* 浅蓝投影 */
    background: rgba(240, 248, 255, 0.3); /* 天青半透明 */
}

/* 4. 音乐按钮：冷调渐变（替代原粉橙渐变） */
.circle-button {
    background: linear-gradient(135deg, #4fc3f7, #29b6f6); /* 浅蓝→亮蓝渐变 */
}

/* 5. 卡片（.tile）优化：冷调反光 */
.tile {
    background: linear-gradient(145deg, #ffffff, #f8fdff); /* 冷调亮白渐变 */
    color: #2c3e50; /* 深灰蓝文字 */
}

/* 6. 排行榜/积分面板：冷调半透明 */
.score-panel, .leaderboard {
    background: rgba(240, 248, 255, 0.2); /* 天青半透明 */
    border: 2px solid rgba(173, 216, 230, 0.3); /* 浅蓝边框 */
    color: #2c3e50; /* 深灰蓝文字 */
}

/* 7. 游戏说明面板：冷调背景 */
.tutorial-panel {
    background: rgba(44, 62, 80, 0.9); /* 深灰蓝半透明 */
    border: 2px solid rgba(173, 216, 230, 0.2); /* 浅蓝边框 */
}


/* 游戏区域背景优化：与整体色调更协调 */
.play-area {
    width: 500px;
    height: 500px;
    /* 原：background: rgba(255, 255, 255, .15) */
    background: rgba(255, 244, 230, 0.2); /* 乳白半透明，与body渐变的#fff4e6呼应 */
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 0, 0, .2);
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 235, 210, 0.3); /* 调整为暖黄边框，更自然 */
    transition: all 0.3s ease;
}

/* 信息面板背景优化：保持半透明但色调更统一 */
.info-panel {
    color: #5d4e3a; /* 原白色→暖棕，与米色调背景更协调 */
    margin: 10px 0;
    font-size: 1.2em;
    text-shadow: 1px 1px 2px rgba(255, 235, 210, 0.3); /* 调整为暖黄投影 */
    /* 原：background: rgba(255, 255, 255, 0.2) */
    background: rgba(255, 244, 230, 0.3); /* 与play-area同色调的半透明 */
    padding: 10px 20px;
    border-radius: 15px;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.info-panel:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.25);
}

.circle-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #fc758c 30%, #f79156 70%);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, .3);
    position: relative;
    top: -700px;
    right: -200px;
    transition: all 0.3s ease-in-out;
}

.circle-button:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}

.play-area {
    width: 500px;
    height: 500px;
    background: rgba(255, 255, 255, .15);
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 0, 0, .2);
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.play-area:hover {
    box-shadow: 0 0 40px rgba(0, 0, 0, .3);
    transform: translateY(-5px);
}

.grid-cell {
    width: 25px;
    height: 25px;
    float: left;
    position: relative;
    border: 1px solid rgba(238, 238, 238, 0.5);
    transition: background-color 0.2s ease;
}

.grid-cell:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.selection-bar {
    width: 433px;
    height: 70px;
    background: rgba(255, 255, 255, .2);
    border-radius: 15px;
    margin: 30px 0;
    padding: 10px;
    display: flex;
    gap: 10px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.selection-bar:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.slot {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, .5);
    border-radius: 8px;
    position: relative;
    box-shadow: 0 3px 6px rgba(0, 0, 0, .2);
    transition: all 0.3s ease;
}

.slot:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, .3);
}

.rotate {
    animation: spin 3s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.tile {
    width: 50px;
    height: 50px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    position: absolute;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #2c3e50;
    animation: pop 0.3s ease-out;
}

.tile:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}

.tile::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    transition: all 0.3s ease;
}

.tile:hover::before {
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.overlay {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, .5);
    position: absolute;
    border-radius: 8px;
    backdrop-filter: blur(3px);
    transition: all 0.3s ease;
}

.overlay:hover {
    background: rgba(255, 255, 255, .6);
    backdrop-filter: blur(5px);
}

@keyframes shine {
    0% { background-position: -100% 50%; }
    100% { background-position: 200% 50%; }
}

.tile.matched {
    animation: pop 0.5s ease-out, shine 2s linear infinite;
    background: linear-gradient(90deg, 
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.8) 50%,
        rgba(255,255,255,0) 100%);
    background-size: 200% 100%;
}

/* 积分面板样式 */
.score-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    min-width: 150px;
}

.score-panel:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.score-value {
    font-size: 2em;
    font-weight: bold;
    text-align: center;
    margin: 5px 0;
    animation: scorePop 0.3s ease-out;
}

@keyframes scorePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* 排行榜样式 */
.leaderboard {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: rgba(240, 248, 255, 0.9); /* 调整为不透明冷调背景（原半透明可能导致文字不清） */
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(173, 216, 230, 0.3); /* 浅蓝边框 */
    color: #333; /* 关键修改：文字主色改为深灰黑 */
    min-width: 200px;
    max-height: 400px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.leaderboard:hover {
    transform: translateY(-50%) translateX(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.leaderboard h2 {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.5em;
    text-shadow: 1px 1px 2px rgba(173, 216, 230, 0.3); /* 冷调投影 */
    color: #2c3e50; /* 标题加深为深灰蓝 */
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.8); /* 调整为更清晰的白色背景 */
    border-radius: 8px;
    transition: all 0.2s ease;
}

.player-score {
    font-weight: bold;
    color: #333; /* 关键修改：分数文字改黑色 */
}

/* 帮助按钮（修复闭合问题） */
.help-button:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #3498db, #2ecc71);
}

.leaderboard-list {
    list-style: none;
}

.leaderboard-item:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.2);
}

.rank {
    font-weight: bold;
    font-size: 1.2em;
    min-width: 30px;
}

.player-name {
    flex-grow: 1;
    margin: 0 10px;
}

.player-score {
    font-weight: bold;
    color: #fff;
}

/* 前三名特殊样式 */
.leaderboard-item:nth-child(1) {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
}

.leaderboard-item:nth-child(2) {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.3), rgba(192, 192, 192, 0.1));
}

.leaderboard-item:nth-child(3) {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.3), rgba(205, 127, 50, 0.1));
}

/* 滚动条美化 */
.leaderboard::-webkit-scrollbar {
    width: 6px;
}

.leaderboard::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.leaderboard::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.leaderboard::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* 积分动画 */
@keyframes scoreIncrease {
    0% { transform: scale(1); color: #fff; }
    50% { transform: scale(1.3); color: #ffd700; }
    100% { transform: scale(1); color: #fff; }
}

.score-increase {
    animation: scoreIncrease 0.5s ease-out;
}

/* 新纪录提示 */
.new-record {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ffd700, #ff9000);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8em;
    opacity: 0;
    animation: newRecord 2s ease-out forwards;
}

@keyframes newRecord {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    20% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* 游戏信息栏 */
.game-info-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 10px 0;
}

/* 帮助按钮 */
.help-button {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.help-button:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #3498db, #2ecc71);
}

/* 游戏说明面板 */
.tutorial-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(44, 62, 80, 0.95);
    padding: 30px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 90%;
    max-width: 500px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.tutorial-panel.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

.tutorial-content {
    position: relative;
}

.tutorial-content h2 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.8em;
    color: #3498db;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.close-btn {
    position: absolute;
    top: -20px;
    right: -20px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 24px;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.tutorial-steps {
    margin-bottom: 30px;
}

.step {
    display: flex;
    align-items: center;
    margin: 15px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.step:hover {
    transform: translateX(10px);
    background: rgba(255, 255, 255, 0.15);
}

.step-number {
    width: 30px;
    height: 30px;
    background: #3498db;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    margin-right: 15px;
    flex-shrink: 0;
}

.step-text {
    font-size: 1.1em;
    line-height: 1.4;
}

.scoring-rules {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.scoring-rules h3 {
    color: #3498db;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.scoring-rules ul {
    list-style: none;
    padding: 0;
}

.scoring-rules li {
    margin: 10px 0;
    padding-left: 20px;
    position: relative;
}

.scoring-rules li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: #3498db;
    font-size: 1.2em;
}

/* 调整其他元素的z-index确保正确的层级关系 */
.score-panel, .leaderboard {
    z-index: 100;
}

/* 添加背景遮罩 */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.tutorial-overlay.show {
    opacity: 1;
    visibility: visible;
}
